# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=dsd
pkgver=v1.6.0.r96.g59423fa
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-misc')
pkgdesc='Digital Speech Decoder.'
arch=('x86_64' 'aarch64')
url='https://github.com/szechyjs/dsd'
license=('GPL-2.0-only')
depends=('libsndfile' 'mbelib' 'itpp' 'portaudio')
makedepends=('git' 'cmake')
source=("git+https://github.com/szechyjs/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd $pkgname

  mkdir -p build

  cd build

  cmake ../ \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
    -DCMAKE_INSTALL_PREFIX=/usr

  make
}

package() {
  cd "$pkgname/build"

  make DESTDIR="$pkgdir" install

  cd ..

  install -Dm 644 -t  "$pkgdir/usr/share/doc/$pkgname/" README.md CHANGELOG
  install -Dm 644 COPYRIGHT "$pkgdir/usr/share/licenses/$pkgname/COPYRIGHT"
}

